### Alizade, Dancygier, Ditlmann 
### "National Penalties Reversed"
### Replication Code 
### Table A9
### For questions, contact jalizade@princeton.edu

# empty environment
rm(list = ls())

#setwd("")
setwd("C:/Users/Jey/Dropbox/WZB/NaturalizationExperiment/Submission/JOP/replication_JOP/data")

# load necessary packages
library(readstata13)

# load data set
dat <- read.dta13("data_broadband.dta")

# means
tapply(dat$`16mbit_pct`, dat$insample, FUN=mean)
tapply(dat$`50mbit_pct`, dat$insample, FUN=mean)
tapply(dat$`100mbit_pct`, dat$insample, FUN=mean)

# difference in means
mean(dat$`16mbit_pct`[dat$insample=="In Sample"])-mean(dat$`16mbit_pct`[dat$insample=="Not in Sample"])
mean(dat$`50mbit_pct`[dat$insample=="In Sample"])-mean(dat$`50mbit_pct`[dat$insample=="Not in Sample"])
mean(dat$`100mbit_pct`[dat$insample=="In Sample"])-mean(dat$`100mbit_pct`[dat$insample=="Not in Sample"])

# p-values
t.test(dat$`16mbit_pct`~dat$insample)$p.value
t.test(dat$`50mbit_pct`~dat$insample)$p.value
t.test(dat$`100mbit_pct`~dat$insample)$p.value
